package com.qf.dao;

import com.qf.entity.User;
import com.qf.util.JdbcUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * @author zdl
 * @date 2025/1/19
 */
public class UserDao {
    public User selectUserByUserNameAndPassword(String name,String password){
        Connection conn = JdbcUtils.getConnection();
        QueryRunner qr = new QueryRunner();
        String sql  = "select * from tb_user where username = ? and password = ?";
        try {
            User query = qr.query(conn, sql, new BeanHandler<>(User.class), name,password);
            return query;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
